home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-ppc-src / pasm / elf.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  3KB  |  169 lines

  1. /* $VER: pasm elf.h V0.2 (23.03.97)
  2.  *
  3.  * This file is part of pasm, a portable PowerPC assembler.
  4.  * Copyright (c) 1997-98  Frank Wille
  5.  *
  6.  * pasm is freeware and part of the portable and retargetable ANSI C
  7.  * compiler vbcc, copyright (c) 1995-98 by Volker Barthelmann.
  8.  * pasm may be freely redistributed as long as no modifications are
  9.  * made and nothing is charged for it. Non-commercial usage is allowed
  10.  * without any restrictions.
  11.  * EVERY PRODUCT OR PROGRAM DERIVED DIRECTLY FROM MY SOURCE MAY NOT BE
  12.  * SOLD COMMERCIALLY WITHOUT PERMISSION FROM THE AUTHOR.
  13.  *
  14.  *
  15.  * v0.2   (25.03.97) phx
  16.  *        Writes ELF object for 32-bit PowerPC big-endian. Either absolute
  17.  *        or ELF output format may be selected. ELF is default for all
  18.  *        currently supported platforms. PPCasm supports nine different
  19.  *        relocation types (there are much more...).
  20.  *        Compiles and works also under NetBSD/amiga (68k).
  21.  *        Changed function declaration to 'new style' in all sources
  22.  *        (to avoid problems with '...' for example).
  23.  *        File created.
  24.  */
  25.  
  26.  
  27. #define EI_NIDENT 16
  28.  
  29. struct Elf32_Ehdr {
  30.   unsigned char e_ident[EI_NIDENT];
  31.   uint16 e_type;
  32.   uint16 e_machine;
  33.   uint32 e_version;
  34.   uint32 e_entry;
  35.   uint32 e_phoff;
  36.   uint32 e_shoff;
  37.   uint32 e_flags;
  38.   uint16 e_ehsize;
  39.   uint16 e_phentsize;
  40.   uint16 e_phnum;
  41.   uint16 e_shentsize;
  42.   uint16 e_shnum;
  43.   uint16 e_shstrndx;
  44. };
  45.  
  46. /* e_indent indexes */
  47. #define EI_MAG0 0
  48. #define EI_MAG1 1
  49. #define EI_MAG2 2
  50. #define EI_MAG3 3
  51. #define EI_CLASS 4
  52. #define EI_DATA 5
  53. #define EI_VERSION 6
  54. #define EI_PAD 7
  55.  
  56. /* EI_CLASS */
  57. #define ELFCLASSNONE 0
  58. #define ELFCLASS32 1
  59. #define ELFCLASS64 2
  60.  
  61. /* EI_DATA */
  62. #define ELFDATANONE 0
  63. #define ELFDATA2LSB 1
  64. #define ELFDATA2MSB 2
  65.  
  66. /* e_type */
  67. #define ET_NONE 0
  68. #define ET_REL 1
  69. #define ET_EXEC 2
  70. #define ET_DYN 3
  71. #define ET_CORE 4
  72.  
  73. /* e_version */
  74. #define EV_NONE 0
  75. #define EV_CURRENT 1
  76.  
  77. /* e_machine */
  78. #define EM_NONE 0
  79. #define EM_M32 1
  80. #define EM_SPARC 2
  81. #define EM_386 3
  82. #define EM_68K 4
  83. #define EM_88K 5
  84. #define EM_860 7
  85. #define EM_MIPS 8
  86. #define EM_POWERPC 20
  87.  
  88.  
  89. struct Elf32_Shdr {
  90.   uint32 sh_name;
  91.   uint32 sh_type;
  92.   uint32 sh_flags;
  93.   uint32 sh_addr;
  94.   uint32 sh_offset;
  95.   uint32 sh_size;
  96.   uint32 sh_link;
  97.   uint32 sh_info;
  98.   uint32 sh_addralign;
  99.   uint32 sh_entsize;
  100. };
  101.  
  102. /* special sections indexes */
  103. #define SHN_UNDEF 0
  104. #define SHN_ABS 0xfff1
  105. #define SHN_COMMON 0xfff2
  106.  
  107. /* sh_type */
  108. #define SHT_NULL 0
  109. #define SHT_PROGBITS 1
  110. #define SHT_SYMTAB 2
  111. #define SHT_STRTAB 3
  112. #define SHT_RELA 4
  113. #define SHT_HASH 5
  114. #define SHT_DYNAMIC 6
  115. #define SHT_NOTE 7
  116. #define SHT_NOBITS 8
  117. #define SHT_REL 9
  118. #define SHT_SHLIB 10
  119. #define SHT_DYNSYM 11
  120.  
  121. /* sh_flags */
  122. #define SHF_WRITE 0x1
  123. #define SHF_ALLOC 0x2
  124. #define SHF_EXECINSTR 0x4
  125.  
  126.  
  127. struct Elf32_Sym {
  128.   uint32 st_name;
  129.   uint32 st_value;
  130.   uint32 st_size;
  131.   uint8 st_info;
  132.   uint8 st_other;
  133.   uint16 st_shndx;
  134. };
  135.  
  136. /* st_info */
  137. #define ELF32_ST_BIND(i) ((i)>>4)
  138. #define ELF32_ST_TYPE(i) ((i)&0xf)
  139. #define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
  140.  
  141. /* ST_BIND */
  142. #define STB_LOCAL 0
  143. #define STB_GLOBAL 1
  144. #define STB_WEAK 2
  145.  
  146. /* ST_TYPE */
  147. #define STT_NOTYPE 0
  148. #define STT_OBJECT 1
  149. #define STT_FUNC 2
  150. #define STT_SECTION 3
  151. #define STT_FILE 4
  152.  
  153.  
  154. struct Elf32_Rel {
  155.   uint32 r_offset;
  156.   uint32 r_info;
  157. };
  158.  
  159. struct Elf32_Rela {
  160.   uint32 r_offset;
  161.   uint32 r_info;
  162.   uint32 r_addend;
  163. };
  164.  
  165. /* r_info */
  166. #define ELF32_R_SYM(i) ((i)>>8)
  167. #define ELF32_R_TYPE(i) ((unsigned char)(i))
  168. #define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
  169.